﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Twodi.Aspect.Interfaces;
using Twodi.Interfaces;
using Twodi.Aspect.Implemented;

namespace Twodi.Implemented
{
    public class Component : DrawableGameComponent, IPositionAspect, ISizeAspect, IRotationAspect, IScaleAspect, IBoundsAspect, ILimitedAspect, ITransformationAspect
    {
        public Component(Game game)
            : base(game)
        {
            this.PositionProperties = new PositionAspect();
            this.SizeProperties = new SizeAspect();
            this.RotationProperties = new RotationAspect();

            this.ScaleProperties = new ScaleAspect(this);
            this.BoundsProperties = new BoundsAspect(this); 
            this.LimitedProperties = new LimitedAspect(this);
            this.TransformationProperties = new DynamicTransformationAspect(this);
        }

        public Vector2 Position
        {
            get
            {
                return this.PositionProperties.Position;
            }
            set
            {
                this.PositionProperties.Position = value;
            }
        }

        public Vector2 Size
        {
            get
            {
                return this.SizeProperties.Size;
            }
            set
            {
                this.SizeProperties.Size = value;
            }
        }

        public float Scale
        {
            get
            {
                return this.ScaleProperties.Scale;
            }
            set
            {
                this.ScaleProperties.Scale = value;
            }
        }

        public Vector2 Origin
        {
            get
            {
                return this.RotationProperties.Origin;
            }
            set
            {
                this.RotationProperties.Origin = value;
            }
        }

        public float Angle
        {
            get
            {
                return this.RotationProperties.Angle;
            }
            set
            {
                this.RotationProperties.Angle = value;
            }
        }

        public Rectangle Bounds
        {
            get
            {
                return this.BoundsProperties.Bounds;
            }
        }

        public Matrix Transformation
        {
            get
            {
                return this.TransformationProperties.Transformation;
            }
        }

        /// <summary>
        /// Limites do componente.
        /// </summary>
        public Rectangle Limits
        {
            get
            {
                return this.LimitedProperties.Limits;
            }
            set
            {
                this.LimitedProperties.Limits = value;
            }
        }

        public IPosition PositionProperties
        {
            get;
            set;
        }

        public ISize SizeProperties
        {
            get;
            set;
        }

        public IRotation RotationProperties
        {
            get;
            set;
        }

        public IBounds BoundsProperties
        {
            get;
            set;
        }

        public IScale ScaleProperties
        {
            get;
            set;
        }

        public ILimited LimitedProperties
        {
            get;
            set;
        }

        public ITransformation TransformationProperties
        {
            get;
            set;
        }
    }
}
